/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package GM.impl;

import GM.Definition;
import GM.Entity;
import GM.Event;
import GM.GMPackage;
import GM.Operation;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Operation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link GM.impl.OperationImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getDompre <em>Dompre</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getDompost <em>Dompost</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getReqpre <em>Reqpre</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getReqpost <em>Reqpost</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getTrigpre <em>Trigpre</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getIn <em>In</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getOut <em>Out</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getHasev <em>Hasev</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getMinExecTImes <em>Min Exec TImes</em>}</li>
 *   <li>{@link GM.impl.OperationImpl#getMaxExecTimes <em>Max Exec Times</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OperationImpl extends ObjectImpl implements Operation {
	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getDompre() <em>Dompre</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDompre()
	 * @generated
	 * @ordered
	 */
	protected Definition dompre;

	/**
	 * The cached value of the '{@link #getDompost() <em>Dompost</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDompost()
	 * @generated
	 * @ordered
	 */
	protected Definition dompost;

	/**
	 * The cached value of the '{@link #getReqpre() <em>Reqpre</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReqpre()
	 * @generated
	 * @ordered
	 */
	protected Definition reqpre;

	/**
	 * The cached value of the '{@link #getReqpost() <em>Reqpost</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReqpost()
	 * @generated
	 * @ordered
	 */
	protected Definition reqpost;

	/**
	 * The cached value of the '{@link #getTrigpre() <em>Trigpre</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTrigpre()
	 * @generated
	 * @ordered
	 */
	protected Definition trigpre;

	/**
	 * The cached value of the '{@link #getIn() <em>In</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIn()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> in;

	/**
	 * The cached value of the '{@link #getOut() <em>Out</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOut()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> out;

	/**
	 * The cached value of the '{@link #getHasev() <em>Hasev</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasev()
	 * @generated
	 * @ordered
	 */
	protected EList<Event> hasev;

	/**
	 * The default value of the '{@link #getMinExecTImes() <em>Min Exec TImes</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinExecTImes()
	 * @generated
	 * @ordered
	 */
	protected static final int MIN_EXEC_TIMES_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMinExecTImes() <em>Min Exec TImes</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinExecTImes()
	 * @generated
	 * @ordered
	 */
	protected int minExecTImes = MIN_EXEC_TIMES_EDEFAULT;

	/**
	 * The default value of the '{@link #getMaxExecTimes() <em>Max Exec Times</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxExecTimes()
	 * @generated
	 * @ordered
	 */
	protected static final int MAX_EXEC_TIMES_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMaxExecTimes() <em>Max Exec Times</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxExecTimes()
	 * @generated
	 * @ordered
	 */
	protected int maxExecTimes = MAX_EXEC_TIMES_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OperationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GMPackage.Literals.OPERATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Definition getDompre() {
		return dompre;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDompre(Definition newDompre, NotificationChain msgs) {
		Definition oldDompre = dompre;
		dompre = newDompre;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__DOMPRE, oldDompre, newDompre);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDompre(Definition newDompre) {
		if (newDompre != dompre) {
			NotificationChain msgs = null;
			if (dompre != null)
				msgs = ((InternalEObject)dompre).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__DOMPRE, null, msgs);
			if (newDompre != null)
				msgs = ((InternalEObject)newDompre).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__DOMPRE, null, msgs);
			msgs = basicSetDompre(newDompre, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__DOMPRE, newDompre, newDompre));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Definition getDompost() {
		return dompost;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDompost(Definition newDompost, NotificationChain msgs) {
		Definition oldDompost = dompost;
		dompost = newDompost;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__DOMPOST, oldDompost, newDompost);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDompost(Definition newDompost) {
		if (newDompost != dompost) {
			NotificationChain msgs = null;
			if (dompost != null)
				msgs = ((InternalEObject)dompost).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__DOMPOST, null, msgs);
			if (newDompost != null)
				msgs = ((InternalEObject)newDompost).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__DOMPOST, null, msgs);
			msgs = basicSetDompost(newDompost, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__DOMPOST, newDompost, newDompost));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Definition getReqpre() {
		return reqpre;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetReqpre(Definition newReqpre, NotificationChain msgs) {
		Definition oldReqpre = reqpre;
		reqpre = newReqpre;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__REQPRE, oldReqpre, newReqpre);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReqpre(Definition newReqpre) {
		if (newReqpre != reqpre) {
			NotificationChain msgs = null;
			if (reqpre != null)
				msgs = ((InternalEObject)reqpre).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__REQPRE, null, msgs);
			if (newReqpre != null)
				msgs = ((InternalEObject)newReqpre).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__REQPRE, null, msgs);
			msgs = basicSetReqpre(newReqpre, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__REQPRE, newReqpre, newReqpre));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Definition getReqpost() {
		return reqpost;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetReqpost(Definition newReqpost, NotificationChain msgs) {
		Definition oldReqpost = reqpost;
		reqpost = newReqpost;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__REQPOST, oldReqpost, newReqpost);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReqpost(Definition newReqpost) {
		if (newReqpost != reqpost) {
			NotificationChain msgs = null;
			if (reqpost != null)
				msgs = ((InternalEObject)reqpost).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__REQPOST, null, msgs);
			if (newReqpost != null)
				msgs = ((InternalEObject)newReqpost).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__REQPOST, null, msgs);
			msgs = basicSetReqpost(newReqpost, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__REQPOST, newReqpost, newReqpost));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Definition getTrigpre() {
		return trigpre;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTrigpre(Definition newTrigpre, NotificationChain msgs) {
		Definition oldTrigpre = trigpre;
		trigpre = newTrigpre;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__TRIGPRE, oldTrigpre, newTrigpre);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTrigpre(Definition newTrigpre) {
		if (newTrigpre != trigpre) {
			NotificationChain msgs = null;
			if (trigpre != null)
				msgs = ((InternalEObject)trigpre).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__TRIGPRE, null, msgs);
			if (newTrigpre != null)
				msgs = ((InternalEObject)newTrigpre).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMPackage.OPERATION__TRIGPRE, null, msgs);
			msgs = basicSetTrigpre(newTrigpre, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__TRIGPRE, newTrigpre, newTrigpre));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getIn() {
		if (in == null) {
			in = new EObjectResolvingEList<Entity>(Entity.class, this, GMPackage.OPERATION__IN);
		}
		return in;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getOut() {
		if (out == null) {
			out = new EObjectResolvingEList<Entity>(Entity.class, this, GMPackage.OPERATION__OUT);
		}
		return out;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Event> getHasev() {
		if (hasev == null) {
			hasev = new EObjectResolvingEList<Event>(Event.class, this, GMPackage.OPERATION__HASEV);
		}
		return hasev;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMinExecTImes() {
		return minExecTImes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMinExecTImes(int newMinExecTImes) {
		int oldMinExecTImes = minExecTImes;
		minExecTImes = newMinExecTImes;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__MIN_EXEC_TIMES, oldMinExecTImes, minExecTImes));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMaxExecTimes() {
		return maxExecTimes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMaxExecTimes(int newMaxExecTimes) {
		int oldMaxExecTimes = maxExecTimes;
		maxExecTimes = newMaxExecTimes;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GMPackage.OPERATION__MAX_EXEC_TIMES, oldMaxExecTimes, maxExecTimes));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case GMPackage.OPERATION__DOMPRE:
				return basicSetDompre(null, msgs);
			case GMPackage.OPERATION__DOMPOST:
				return basicSetDompost(null, msgs);
			case GMPackage.OPERATION__REQPRE:
				return basicSetReqpre(null, msgs);
			case GMPackage.OPERATION__REQPOST:
				return basicSetReqpost(null, msgs);
			case GMPackage.OPERATION__TRIGPRE:
				return basicSetTrigpre(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GMPackage.OPERATION__DESCRIPTION:
				return getDescription();
			case GMPackage.OPERATION__DOMPRE:
				return getDompre();
			case GMPackage.OPERATION__DOMPOST:
				return getDompost();
			case GMPackage.OPERATION__REQPRE:
				return getReqpre();
			case GMPackage.OPERATION__REQPOST:
				return getReqpost();
			case GMPackage.OPERATION__TRIGPRE:
				return getTrigpre();
			case GMPackage.OPERATION__IN:
				return getIn();
			case GMPackage.OPERATION__OUT:
				return getOut();
			case GMPackage.OPERATION__HASEV:
				return getHasev();
			case GMPackage.OPERATION__MIN_EXEC_TIMES:
				return getMinExecTImes();
			case GMPackage.OPERATION__MAX_EXEC_TIMES:
				return getMaxExecTimes();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GMPackage.OPERATION__DESCRIPTION:
				setDescription((String)newValue);
				return;
			case GMPackage.OPERATION__DOMPRE:
				setDompre((Definition)newValue);
				return;
			case GMPackage.OPERATION__DOMPOST:
				setDompost((Definition)newValue);
				return;
			case GMPackage.OPERATION__REQPRE:
				setReqpre((Definition)newValue);
				return;
			case GMPackage.OPERATION__REQPOST:
				setReqpost((Definition)newValue);
				return;
			case GMPackage.OPERATION__TRIGPRE:
				setTrigpre((Definition)newValue);
				return;
			case GMPackage.OPERATION__IN:
				getIn().clear();
				getIn().addAll((Collection<? extends Entity>)newValue);
				return;
			case GMPackage.OPERATION__OUT:
				getOut().clear();
				getOut().addAll((Collection<? extends Entity>)newValue);
				return;
			case GMPackage.OPERATION__HASEV:
				getHasev().clear();
				getHasev().addAll((Collection<? extends Event>)newValue);
				return;
			case GMPackage.OPERATION__MIN_EXEC_TIMES:
				setMinExecTImes((Integer)newValue);
				return;
			case GMPackage.OPERATION__MAX_EXEC_TIMES:
				setMaxExecTimes((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GMPackage.OPERATION__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
			case GMPackage.OPERATION__DOMPRE:
				setDompre((Definition)null);
				return;
			case GMPackage.OPERATION__DOMPOST:
				setDompost((Definition)null);
				return;
			case GMPackage.OPERATION__REQPRE:
				setReqpre((Definition)null);
				return;
			case GMPackage.OPERATION__REQPOST:
				setReqpost((Definition)null);
				return;
			case GMPackage.OPERATION__TRIGPRE:
				setTrigpre((Definition)null);
				return;
			case GMPackage.OPERATION__IN:
				getIn().clear();
				return;
			case GMPackage.OPERATION__OUT:
				getOut().clear();
				return;
			case GMPackage.OPERATION__HASEV:
				getHasev().clear();
				return;
			case GMPackage.OPERATION__MIN_EXEC_TIMES:
				setMinExecTImes(MIN_EXEC_TIMES_EDEFAULT);
				return;
			case GMPackage.OPERATION__MAX_EXEC_TIMES:
				setMaxExecTimes(MAX_EXEC_TIMES_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GMPackage.OPERATION__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
			case GMPackage.OPERATION__DOMPRE:
				return dompre != null;
			case GMPackage.OPERATION__DOMPOST:
				return dompost != null;
			case GMPackage.OPERATION__REQPRE:
				return reqpre != null;
			case GMPackage.OPERATION__REQPOST:
				return reqpost != null;
			case GMPackage.OPERATION__TRIGPRE:
				return trigpre != null;
			case GMPackage.OPERATION__IN:
				return in != null && !in.isEmpty();
			case GMPackage.OPERATION__OUT:
				return out != null && !out.isEmpty();
			case GMPackage.OPERATION__HASEV:
				return hasev != null && !hasev.isEmpty();
			case GMPackage.OPERATION__MIN_EXEC_TIMES:
				return minExecTImes != MIN_EXEC_TIMES_EDEFAULT;
			case GMPackage.OPERATION__MAX_EXEC_TIMES:
				return maxExecTimes != MAX_EXEC_TIMES_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (description: ");
		result.append(description);
		result.append(", minExecTImes: ");
		result.append(minExecTImes);
		result.append(", maxExecTimes: ");
		result.append(maxExecTimes);
		result.append(')');
		return result.toString();
	}

} //OperationImpl
